// 队列 queue - FIFO

// 循环队列 - 击鼓传花

function hotpotato(eliminatedList, num) {
    const queue = new Queue();
    const loserList = [];
    for (let i = 0; i < eliminatedList.length; i++) {
        queue.enqueue(eliminatedList[i]);
    }
    while (queue.size() > 1) {
        for (let i = 0; i < num; i++) {
            queue.enqueue(queue.dequeue());
        }
        loserList.push(queue.dequeue());
    }
    return {
        loser: loserList,
        winner: queue.dequeue()
    }
}

// 回文检查器

function palindromeChecker(aString) {
    if (!aString) {
        return false;
    }
    const deque = new Deque();
    const lowerString = aString.toLocaleLowerCase().split(' ').join('');
    let isEqual = true;
    let firstChar, lastChar;
    for (let i = 0; i < lowerString.length; i++) {
        deque.addBack(lowerString.charAt(i));
    }

    while (deque.size() > 1 && isEqual) {
        firstChar = deque.removeFront();
        lastChar = deque.removeBack();
        if (firstChar !== lastChar) {
            return false;
        }
    }

    return isEqual;
}